package day_2023_7_to_10;

/**
 * @author haomin
 * @date 2023/07/26 23:24
 **/
public class Day_7_26 {
    class Solution {
        public int findRepeatNumber(int[] nums) {
            if(nums.length <= 1) return 0;
            for(int i = 0; i < nums.length; ++i) {
                int a = nums[i];
                int b = nums[a];
                if(a == i) i++;
                else {
                    if(a == b) return a;
                    else {
                        nums[i] = b;
                        nums[a] = a;
                    }
                }
            }
            return 0;
        }
    }
}